<!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta name="renderer" content="webkit">
		<title>总管理登录</title>
		<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
		<link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
		<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
		<link rel="stylesheet" href="dist/css/skins/skin-blue.min.css">
		<link rel="stylesheet" href="css/style.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
		<link rel="icon" href="img/logo.ico" type="image/x-icon" />
		<link rel="stylesheet" href="./css/clear.css" />
		<link rel="stylesheet" href="./css/official.css" />
		<style>

		</style>
	</head>

	<body style="background-color: #ccc;">
		<div class="official-hearder">
			<div class="official-hearder-top">
				<div class="official-content">
					<div class="clearfix">
						<div class="pull-right left-line-between" onclick="offcialExit()">
							退出
						</div>
						<div class="pull-right" id="walletName">
							--
						</div>
					</div>

				</div>
			</div>

			<div class="official-hearder-body clearfix">
				<div class="official-content">
					<div class="official-logo">
						<div style="width:30px;height:30px;background-color: #0C2D5A;"></div>
					</div>

					<div class="pull-right">
						<ul class="clearfix official-ul">
							<li>
								<a href="officialAPI.html">API接口</a>
							</li>
							<li class="active">
								<a href="javascript:;">资产信息</a>
							</li>
							<li>
								<a href="officialDeal.html">交易记录</a>
							</li>
						</ul>
					</div>
				</div>
			</div>
			<!--<div class="official-hearder-bottom clearfix">
				<div class="official-content">
					<h1>科学·社会</h1>
					<h3>名主富强和谐友善公正</h3>
				</div>
			</div>-->
		</div>
		<div class="official-body" style="margin-top:10px;">
			<div class="official-content" style="background-color: #fff;padding:30px;">
				<ul class="clearfix official-ul" id="coin_list"></ul>
				<div>
					<table id="example" class="display nowrap table table-bordered table-striped" style="width:100%;">
						<thead>
							<tr>
								<th>名称</th>
								<th>余额</th>
							</tr>
						</thead>
						<tbody></tbody>
					</table>
				</div>
			</div>
		</div>
		<script src="bower_components/jquery/dist/jquery.min.js"></script>
		<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
		<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>

		<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>

		<script src="dist/js/adminlte.min.js"></script>
		<script type="text/javascript" src="js/argument.js"></script>
		<script type="text/javascript" src="js/fun.js"></script>
		<script type="text/javascript">
			$("#walletName").text(localStorage.getItem("official_wallet_name"))
			var table;
			$.ajax({
				"type": 'post',
				"url": url + 'Home_MainChain',
				'contentType': "application/x-www-form-urlencoded",
				"headers": {
					"auth-token": localStorage.getItem("official_wallet_token")
				},
				async: false,
				success: function(res) {
					if(res.status == 1) {
						//render();
						$.each(res.data, function(index, item) {
							var active = "";
							if(index == 0) {
								active = "active";
							}
							$("#coin_list").append('<li class="' + active + '" coin_id="' + item.id + '"> <a href="javascript:;">' + item.name + '</a> </li>')
						
						})
						table = $('#example').DataTable({
							'ordering': false,
							'lengthChange': false,
							'searching': false,
							'info': true,
							"processing": true,
							"serverSide": true,
							'scrollX':true,
							"ajax": {
								"type": 'post',
								"url": url + "Home_UserCoinList",
								'contentType': "application/x-www-form-urlencoded",
								"headers": {
									"auth-token": localStorage.getItem("official_wallet_token")
								},
								"data": function(d) {
									var data = {};
									data.data = JSON.stringify({change_type:1,chain_id:$("#coin_list li.active").attr('coin_id')})
									return data;
								},
								"dataFilter": function(data) {
									var datajson = eval('(' + data + ')');
									if(datajson.status == 1000||datajson.status == 102) {
										ToLogin(datajson)
										return false;
									} else if(datajson.status != 1) {
										alert(datajson.error);
										return false;
									}
									var json = {};
									if(datajson.data == null) {
										json.recordsTotal = 0;
										json.recordsFiltered = 0;
										json.data = [];
										return JSON.stringify(json);
									} else {
										
										datajson.data.coin_list = [
								            {
								                "id": 6,
								                "name": "TEP",
								                "logo": "11",
								                "balance_show": 0.0,
								                "coin_id": 1,
								                "change_balace": 1.11
								            },
								            {
								                "id": 7,
								                "name": "ETH",
								                "logo": "22",
								                "balance_show": 0.0,
								                "coin_id": 2,
								                "change_balace": 1.11
								            }
								        ];
										json.recordsTotal = datajson.data.coin_list.length;
										json.recordsFiltered = datajson.data.coin_list.length;
										json.data = datajson.data.coin_list;
										return JSON.stringify(json);
									}
								}
							},
							"columns": [{
									data: null,render:function(data){
										return '<img src="'+data.logo+'"/>'+data.name	
									}
								},
								{
									data: 'balance_show'
								}
							]
						})
					} else if(res.status == 1000||res.status == 102) {
						alert("登录过期");
						window.location.href = "officialLogin.html";
					} else {
						alert(res.error)
						return false;
					}
				}
			})
			
			$("#coin_list").on('click', 'li', function() {
				if(!$(this).hasClass('active')) {
					var id = $(this).attr("coin_id");
					$(this).addClass('active').siblings().removeClass("active");
					table.ajax.reload(false)
				}
			})
		</script>
	</body>

</html>